<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Widthr extends Base
{
    

    const STATUS_NO_EXAMINE  = 1; // 未审核
    const STATUS_HAS_EXAMINE = 2; // 已审
    const STATUS_FINISHED    = 3; // 已完成
    const STATUS_REFUSE      = 4; // 拒绝

    protected $table = 'wd_system_withdrawals';

    /**
     * 获得店铺的未接提现和已结提现
     * @return [type] [description]
     */
    public function getWithdrInfo ($id) 
    {
        //获得店铺提现通过的总资金
        $finished    = $this->where('status', self::STATUS_FINISHED)->where('shopid', $id)->sum('money');

        //获得店铺提现通过的总资金
        $no_finished = $this->whereIn('status', [self::STATUS_NO_EXAMINE,self::STATUS_HAS_EXAMINE])->where('shopid', $id)->sum('money');

        return ['finished' => $finished, 'no_finished' => $no_finished];
    }
}
